<?php

class MessagerController extends Controller
{
    public function actionIndex()
    {
        $configs = $this->connection->createCommand("select * from sys_config where module = 'messager' order by seq asc ")->queryAll();

        $this->render('index',['configs'=>$configs]);
    }

    public function actionSaveconfig(){
        $accessKeyId = $_REQUEST['accessKeyId'];
        $accessKeySecret = $_REQUEST['accessKeySecret'];

        $this->connection->createCommand("update sys_config set config_value = {$accessKeyId} where config_key = 'accessKeyId' and module = 'messager' ")->execute();
        $this->connection->createCommand("update sys_config set config_value = {$accessKeySecret} where config_key = 'accessKeySecret' and module = 'messager' ")->execute();

        echo json_encode(Appcode::success);
    }

}